﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class CMS_Admin_block_CacheView : System.Web.UI.Page
{
    Usas.BLL.Cms.cms_block_common_detail cbcd = new Usas.BLL.Cms.cms_block_common_detail();
    Usas.Model.Cms.cms_block_common_detail cbcdm = new Usas.Model.Cms.cms_block_common_detail();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string id = Request["control"].ToString();
            string type = Request["page"].ToString();

            DataSet ds = cbcd.GetList("c_b_id=" + id + " and c_type='" + type + "'");

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["c_value"].ToString() == "1")
                {
                    RB1.Checked = true;
                }
                else
                {
                    RB2.Checked = true;
                }
            }
        }
    }

    protected void save_Click(object sender, EventArgs e)
    {
        string id = Request["control"].ToString();
        string type = Request["page"].ToString();
        int view = 1;


        List<Usas.Model.Cms.cms_block_common_detail> ls = new List<Usas.Model.Cms.cms_block_common_detail>();


        Usas.Model.Cms.cms_block_common_detail cm = new Usas.Model.Cms.cms_block_common_detail();
        cm.c_type = type;
        cm.c_b_id = Convert.ToInt32(id);
        cm.c_view = view;
        cm.c_value = RB1.Checked ? "1" : "2";
        cm.c_des = "内容展现形式";
        ls.Add(cm);



        if (ls.Count > 0)
        {
            if (cbcd.SetNewDetail("c_b_id=" + id + " and c_type='" + type + "'", ls) > 0)
            {
                ClientScript.RegisterStartupScript(GetType(), "Msg", "alert('执行成功！');parent.location.reload()", true);
            }
        }
    }
}
